In [1]:
import radarsimpy
radarsimpy.__version__
Out[1]:
'11.1.0'

Receiver Operating Characteristic (ROC)¶

Calculate the receiver operation characteristic in a radar.

Requires¶

  • numpy
  • scipy
  • plotly (visualization)

Calculate $P_d$ from $SNR$ and $P_{fa}$¶

Swerling 3 targets without integration¶

In [2]:
from radarsimpy.tools import roc_pd, roc_snr
import numpy as np

snr = np.arange(-10, 10, 0.1)
pfa = np.array([1e-4, 1e-5])
pd = roc_pd(pfa, snr, 64, 'Swerling 3')
In [3]:
import plotly.graph_objs as go
from plotly.offline import iplot

it_pfa = np.nditer(pfa, flags=['f_index'])


data = []
while not it_pfa.finished:
    data.append(go.Scatter(
        x=snr, y=pd[it_pfa.index, :], name='Pfa = '+str(it_pfa[0])))
    it_pfa.iternext()

layout = go.Layout(
    title='Swerling 3, N = 64',
    yaxis=dict(title='Probability of detection Pd'),
    xaxis=dict(title='SNR (dB)'),
    height=600,
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

Swerling 3 targets with 20-channel non-coherent integration¶

In [4]:
pd = roc_pd(pfa, snr, 20, 'Swerling 3')
In [5]:
it_pfa = np.nditer(pfa, flags=['f_index'])
data = []
while not it_pfa.finished:
    data.append(go.Scatter(
        x=snr, y=pd[it_pfa.index, :], name='Pfa = '+str(it_pfa[0])))
    it_pfa.iternext()


layout = go.Layout(
    title='Swerling 3, N = 20',
    yaxis=dict(title='Probability of detection Pd'),
    xaxis=dict(title='SNR (dB)'),
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

Different target types¶

In [6]:
snr = np.arange(-10, 30, 0.1)
pfa = 1e-6
N = 5
pd_sw1 = roc_pd(pfa, snr, N, 'Swerling 1')
pd_sw2 = roc_pd(pfa, snr, N, 'Swerling 2')
pd_sw3 = roc_pd(pfa, snr, N, 'Swerling 3')
pd_sw4 = roc_pd(pfa, snr, N, 'Swerling 4')
pd_sw5 = roc_pd(pfa, snr, N, 'Swerling 5')
pd_coherent = roc_pd(pfa, snr, N, 'Coherent')
pd_real = roc_pd(pfa, snr, N, 'Real')
In [7]:
data = []
data.append(go.Scatter(x=snr, y=pd_sw1, name='Swerling 1'))
data.append(go.Scatter(x=snr, y=pd_sw2, name='Swerling 2'))
data.append(go.Scatter(x=snr, y=pd_sw3, name='Swerling 3'))
data.append(go.Scatter(x=snr, y=pd_sw4, name='Swerling 4'))
data.append(go.Scatter(x=snr, y=pd_sw5, name='Swerling 5'))
data.append(go.Scatter(x=snr, y=pd_coherent, name='Coherent'))
data.append(go.Scatter(x=snr, y=pd_real, name='Real'))


layout = go.Layout(
    title='Pfa = '+str(pfa)+', N = '+str(N),
    yaxis=dict(title='Probability of detection Pd'),
    xaxis=dict(title='SNR (dB)'),
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

Calculate minimal required $SNR$ from $P_d$ and $P_{fa}$¶

In [8]:
pfa = 1e-5
pd = np.arange(0.1, 0.9, 0.01)
N = 10
snr_real = roc_snr(1e-4, pd, N, 'Real')

snr_sw1 = roc_snr(pfa, pd, N, 'Swerling 1')
snr_sw2 = roc_snr(pfa, pd, N, 'Swerling 2')
snr_sw3 = roc_snr(pfa, pd, N, 'Swerling 3')
snr_sw4 = roc_snr(pfa, pd, N, 'Swerling 4')
snr_sw5 = roc_snr(pfa, pd, N, 'Swerling 5')
snr_coherent = roc_snr(pfa, pd, N, 'Coherent')
snr_real = roc_snr(pfa, pd, N, 'Real')
In [9]:
data = []
data.append(go.Scatter(x=pd, y=snr_sw1, name='Swerling 1'))
data.append(go.Scatter(x=pd, y=snr_sw2, name='Swerling 2'))
data.append(go.Scatter(x=pd, y=snr_sw3, name='Swerling 3'))
data.append(go.Scatter(x=pd, y=snr_sw4, name='Swerling 4'))
data.append(go.Scatter(x=pd, y=snr_sw5, name='Swerling 5'))
data.append(go.Scatter(x=pd, y=snr_coherent, name='Coherent'))
data.append(go.Scatter(x=pd, y=snr_real, name='Real'))


layout = go.Layout(
    title='Pfa = '+str(pfa)+', N = '+str(N),
    xaxis=dict(title='Probability of detection Pd'),
    yaxis=dict(title='Minimal SNR (dB)'),
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

Generate a look-up table¶

In [10]:
snr_sw1 = np.zeros(256)
snr_sw2 = np.zeros(256)
snr_sw3 = np.zeros(256)
snr_sw4 = np.zeros(256)
snr_sw5 = np.zeros(256)
snr_ci = np.zeros(256)
pd = 0.5
pfa = 1e-4

for N in range(1, 257):
    snr_sw1[N-1] = roc_snr(pfa, pd, N, 'Swerling 1')
    snr_sw2[N-1] = roc_snr(pfa, pd, N, 'Swerling 2')
    snr_sw3[N-1] = roc_snr(pfa, pd, N, 'Swerling 3')
    snr_sw4[N-1] = roc_snr(pfa, pd, N, 'Swerling 4')
    snr_sw5[N-1] = roc_snr(pfa, pd, N, 'Swerling 5')
    snr_ci[N-1] = roc_snr(pfa, pd, N, 'Coherent')


mat = np.zeros((256, 6))
mat[:, 0] = snr_sw1
mat[:, 1] = snr_sw2
mat[:, 2] = snr_sw3
mat[:, 3] = snr_sw4
mat[:, 4] = snr_sw5
mat[:, 5] = snr_ci

np.savetxt("../data/snr.csv", mat, delimiter=",")
In [ ]: